package com.ydles.goods.handler;

import ccom.ydles.entity.Result;
import ccom.ydles.entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一的异常处理类
 */
@ControllerAdvice //controller的增强类
public class BaseExceptionHand {


    //出了错
    @ExceptionHandler(Exception.class)
    @ResponseBody //返回json格式
    public Result handleException(Exception e){
        //打印日志 logger.error("")
        return new Result(false, StatusCode.ERROR,e.getMessage());
    }

}
